package com.kaifamiao.month03.day0330;

import java.util.Arrays;

public class Poetry {

    /**
     * 正常输出
     * @param arr 需要输出的数组
     */
    public static void print(char[][] arr) {

        for (char[] a : arr) {
            for(char i : a){
                System.out.print(i + "\t");
            }
            System.out.println();
        }
    }

    public static void print2(char[][] arr) {
        int maxLen = arr[0].length;
        for (int i = 1; i < arr.length; i ++) {
            if (arr[i].length > maxLen) {
                maxLen = arr[i].length;
            }
        }
        for (int i = 0; i < arr.length; i ++) {
            arr[i] = Arrays.copyOf(arr[i],maxLen);
        }
        for(int i = 0; i < arr[0].length; i ++){
            for (int j = arr.length - 1; j >= 0; j -- ){
                System.out.print(arr[j][i] + "\t");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        char[][] arr = {
                {'白', '日', '依', '山', '尽'},
                {'黄', '河', '入', '海', '流'},
                {'欲', '穷', '千', '里', '目'},
                {'更', '上', '一', '层', '楼'}
        };
        print(arr);
        print2(arr);
        char[][] poem = new char[5][];
        poem[0] = "枯藤老树昏鸦".toCharArray();
        poem[1] = "小桥流水人家".toCharArray();
        poem[2] = "古道西风瘦马".toCharArray();
        poem[3] = "夕阳西下".toCharArray();
        poem[4] = "断肠人在天涯".toCharArray();
        System.out.println("正常输出：");
        print(poem);
        System.out.println("古文输出：");
        print2(poem);
    }
}
